// 首页的接口函数
import { http } from '@/utils/http'
// 引入接口类型
import type { bannerInfoType, homeCategoryType, hotPanelType } from '@/types/home'
import type { guessInfoType } from '@/types/global'

enum API {
  BANNERINFOAPI = '/home/banner',
  CATEGORYINFOAPI = '/home/category/mutli',
  HOTINFOAPI = '/home/hot/mutli',
  GUESSINFOAPI = '/home/goods/guessLike',
}

// 获取轮播图的接口
/* 
    distributionSite 广告区域展示位置
    1 为首页（默认值）
    2 为商品分类页
 */
export const getHomeBannerAPI = (distributionSite: number = 1) => {
  return http<bannerInfoType[]>({
    method: 'GET',
    url: API.BANNERINFOAPI,
    data: {
      distributionSite,
    },
  })
}

// 获取首页分类面板的接口
export const getHomeCategoryAPI = () => {
  return http<homeCategoryType[]>({
    method: 'GET',
    url: API.CATEGORYINFOAPI,
  })
}

// 获取热门推荐模块的接口
export const getHotPanelAPI = () => {
  return http<hotPanelType[]>({
    method: 'GET',
    url: API.HOTINFOAPI,
  })
}

// 获取猜你喜欢模块数据的接口
export const getGuessAPI = (page: number = 1, pageSize: number = 10) => {
  return http<guessInfoType>({
    method: 'GET',
    url: API.GUESSINFOAPI,
    data: {
      page,
      pageSize,
    },
  })
}
